package bairui.international.model.domain.jpa;

/**
 *
 * @see TB_User 用户
 *
 */
public class TestData_TB_User
{

	private final static org.apache.commons.text.RandomStringGenerator Generator = new org.apache.commons.text.RandomStringGenerator.Builder().withinRange(new char[][]{{'a','z'}, {'A','Z'}, {'0','9'}}).build();

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_User saveMust(
		org.springframework.context.ApplicationContext context
		
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_User");
		return (TB_User)repository.save(newMust(
				
			));
	}
	
	public static TB_User newMust(
		
	){
		return new TB_User(new TB_User.MustProperties() {
			/** Openid */
			@Override public String getOpenid(){
				return Generator.generate(0, 255);
			}
			/** 类型 */
			@Override public bairui.international.model.type.Type_User getType(){
				return bairui.international.model.type.Type_User.General;
			}
		});
	}
	

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_User saveAll(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_UserAmount userAmount
	,bairui.international.model.domain.jpa.TB_BranchCompanyStaff sender
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_User");
		return (TB_User)repository.save(newAll(
				userAmount
				,sender
			));
	}
	
	public static TB_User newAll(
		bairui.international.model.domain.jpa.TB_UserAmount userAmount
	,bairui.international.model.domain.jpa.TB_BranchCompanyStaff sender
	){
		return new TB_User(
			new TB_User.MustProperties() {
				/** Openid */
				@Override public String getOpenid(){
					return Generator.generate(0, 255);
				}
				/** 类型 */
				@Override public bairui.international.model.type.Type_User getType(){
					return bairui.international.model.type.Type_User.General;
				}
			},
			new TB_User.OptionalSingleProperties() {
				/** Unionid */
				@Override public String getUnionid(){
					return Generator.generate(0, 255);
				}
				/** 用户登录态标识 */
				@Override public String getSkey(){
					return Generator.generate(0, 255);
				}
				/** 微信登录态标识 */
				@Override public String getSessionKey(){
					return Generator.generate(0, 255);
				}
				/** 昵称 */
				@Override public String getNickName(){
					return Generator.generate(0, 255);
				}
				/** 头像URL */
				@Override public String getAvatarUrl(){
					return Generator.generate(0, 255);
				}
				/** 性别 */
				@Override public String getGender(){
					return Generator.generate(0, 5);
				}
				/** 所在国家 */
				@Override public String getCountry(){
					return Generator.generate(0, 100);
				}
				/** 所在省份 */
				@Override public String getProvince(){
					return Generator.generate(0, 100);
				}
				/** 所在城市 */
				@Override public String getCity(){
					return Generator.generate(0, 100);
				}
				/** 语言 */
				@Override public String getLanguage(){
					return Generator.generate(0, 20);
				}
				/** 真实姓名 */
				@Override public String getRealName(){
					return Generator.generate(0, 30);
				}
				/** 电话 */
				@Override public String getPhone(){
					return Generator.generate(0, 255);
				}
				/** 公司 */
				@Override public String getCompany(){
					return Generator.generate(0, 255);
				}
				/** 二维码 */
				@Override public String getDimensionalUrl(){
					return Generator.generate(0, 255);
				}
				/** 用户账户 */
				@Override public bairui.international.model.domain.jpa.TB_UserAmount getUserAmount(){
					return userAmount;
				}
				/** 提现账号 */
				@Override public String getAccountNumber(){
					return Generator.generate(0, 50);
				}
				/** 开户行 */
				@Override public String getBank(){
					return Generator.generate(0, 100);
				}
				/** 配送员 */
				@Override public bairui.international.model.domain.jpa.TB_BranchCompanyStaff getSender(){
					return sender;
				}
			}
		);
	}
	

}
